﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AutoMapper;

using Revis.VClinicNet.Core.Domain;
using Revis.VClinicNet.Core.Domain.Credentials;

namespace Revis.VClinicNet.App.Internal.Dto.Mappers
{
    public class WorkerUserDtoMapper : IDtoMapper
    {
        public static Func<Worker, string> Name = (w) => {
            return w.FirstName + " " + w.Surname;
        };

        public void Map()
        {
            Mapper.CreateMap<WorkerUser, WorkerUserDto>()
                .ForMember(w => w.FirstName, mo => mo.MapFrom(u => u.RelatedWorker.FirstName))
                .ForMember(w => w.Surname, mo => mo.MapFrom(u => u.RelatedWorker.Surname));

            Mapper.CreateMap<WorkerUser, WorkerUserEditDto>()
                .ForMember(w => w.FirstName, mo => mo.MapFrom(u => u.RelatedWorker.FirstName))
                .ForMember(w => w.Surname, mo => mo.MapFrom(u => u.RelatedWorker.Surname));

            Mapper.CreateMap<WorkerUser, WorkerUserInfoDto>()
                .ForMember(w => w.Name, mo => mo.MapFrom(u => Name(u.RelatedWorker)));
        }
    }
}
